<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>宠你吖</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
	 <div class="layui-col-lg-offset3 layui-col-lg6">
	<div class="layui-form-item">
	                <label class="layui-form-label">序号：</label>
	                <div class="layui-input-block">
	                    <input type="text" id="masterid" name="masterid" lay-verify="mastername" autocomplete="off" disabled="disabled" class="layui-input">
	                </div>
	</div>
			    <div class="layui-form-item">
                    <label class="layui-form-label">名字：</label>
                    <div class="layui-input-block">
                        <input type="text" id="mastername" name="mastername" lay-verify="mastername" autocomplete="off" placeholder="请输入主人呢姓名" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                     <label class="layui-form-label">性别：</label>
                     <div class="layui-input-block">
                         <input type="radio" name="mastersex" value="1" title="男" checked="">
                         <input type="radio" name="mastersex" value="2" title="女">
                     </div>
                 </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">年龄：</label>
                    <div class="layui-input-block">
                        <input type="text" id="masterage" name="masterage" autocomplete="off" placeholder="请输入年龄" class="layui-input">
                    </div>
                </div>
                 <div class="layui-form-item">
                     <label class="layui-form-label">QQ：</label>
                     <div class="layui-input-block">
                         <input type="text" id="masterqq" name="masterqq" autocomplete="off" placeholder="请输入主人qq" class="layui-input">
                     </div>
                 </div>
                 <div class="layui-form-item">
                     <label class="layui-form-label">Phone：</label>
                     <div class="layui-input-block">
                         <input type="text" id="masterphone" name="masterphone" autocomplete="off" placeholder="请输入主人手机号" class="layui-input">
                     </div>
                 </div>
    
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">修改主人信息</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
				</div>
</div>
</div>
<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
            var str=localStorage.getItem("Master");
			var s=JSON.parse(str);
			$("#masterid").val(s.masterid);
			$("#mastername").val(s.mastername);
			$("#mastersex").val(s.mastersex);
			$("#masterage").val(s.masterage);
            $("#masterqq").val(s.masterqq);
            $("#masterphone").val(s.masterphone);
			//监听提交
        form.on('submit(demo1)', function (data) {
			//请求添加接口
			$.post("/api/master/update.do",data.field,function(res){
				if(res.code==10000){
					//修改成功
					location.href="listmaster.html";
				}else{
					//添加失败
					layer.alert("修改失败", {
                    title: '亲，修改失败，请检查网络'
                    })
				}
			})
            return false;
        });
    });
</script>
</body>
</html>